//
//  ZClubCardCell.m
//  WeClubs
//
//  Created by Zed Link on 22/4/2017.
//  Copyright © 2017 Zed. All rights reserved.
//

#import "ZClubCardCell.h"
#import <Masonry.h>

NSString * const ClubCardMemberItemReuseID = @"ZClubCardMemberItemReuseID";

@interface ZClubCardCell ()

@property (weak, nonatomic) IBOutlet UIView *cardView;
@property (weak, nonatomic) IBOutlet UIImageView *logoImgView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *sloganLabel;
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UIButton *albumBtn;
@property (weak, nonatomic) IBOutlet UIButton *activityBtn;
@property (weak, nonatomic) IBOutlet UIButton *likeBtn;
@property (weak, nonatomic) IBOutlet UIButton *followBtn;

@end

@implementation ZClubCardCell

- (void)zSetupCell
{
    [super zSetupCell];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [self.contentView setBackgroundColor:[UIColor clearColor]];
    [self setBackgroundColor:[UIColor clearColor]];
    
    [self.cardView zShadowAndCornerDeal:16];
    [self.cardView setBackgroundColor:NAVBAR_BG_COLOR];
    [self.logoImgView zCornerDeal:26];
    [self.followBtn zCornerDeal:4];
    [self.albumBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -6, 0, 0)];
    [self.activityBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -6, 0, 0)];
    [self.likeBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -6, 0, 0)];
    [self.followBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 8)];
    
    UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layout.itemSize = CGSizeMake(36, 36);
    layout.minimumLineSpacing = 8;
    
    [self.collectionView setBackgroundColor:[UIColor clearColor]];
    self.collectionView.showsHorizontalScrollIndicator = NO;
    [self.collectionView registerClass:[ZClubCardMemberItem class] forCellWithReuseIdentifier:ClubCardMemberItemReuseID];
}

- (IBAction)albumBtnAction:(id)sender
{
}

- (IBAction)activityBtnAction:(id)sender
{
}

- (IBAction)likeBtnAction:(id)sender
{
}

- (IBAction)followBtnAction:(id)sender
{
}

#pragma mark - UICollectionViewDataSource & UICollectionViewDelegate

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ZClubCardMemberItem *item = [collectionView dequeueReusableCellWithReuseIdentifier:ClubCardMemberItemReuseID forIndexPath:indexPath];
    
    return item;
}

@end



@implementation ZClubCardMemberItem

- (void)zSetupCell
{
    // ========== 添加按钮 ==========
    // Todo: 每个item设置不同的头像
    UIImageView *userIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Icon-60"]];
    [userIcon zCornerDeal:18];
    
    self.userIcon = userIcon;
    [self.contentView addSubview:userIcon];
    [userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
}

@end

